/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     struct TreeNode *left;
 *     struct TreeNode *right;
 * };
 */

bool IsSame(struct TreeNode* q, struct TreeNode* p){
    if(!q ^ !p)
        return false;
    if(!q && !p)
        return true;
    return q->val == p->val && IsSame(q->left, p->right) && IsSame(q->right, p->left);
}
bool isSymmetric(struct TreeNode* root){
    if(!root)
        return true;
    return IsSame(root->left, root->right);
}